#!/usr/bin/perl
use strict;
package nsmyinfo;
sub nsmyinfo {
    my ($nsnum,$dbh,$remote,$input) = @_;
    my $sth;
    $sth=$dbh->prepare("SELECT num,nick,host,auth,server FROM ninfo WHERE num = '$$input[0]';");
    $sth->execute;
    my ($num,$nick,$host,$auth,$server);
    while (my @tmp = $sth->fetchrow_array) {
	if ($tmp[0] eq $$input[0]) {
	    $num = $tmp[0];
	    $nick = $tmp[1];
	    $host = $tmp[2];
	    $auth = $tmp[3];
	    $server = $tmp[4];
	}
    }
  
    print $remote "$nsnum O $$input[0] :Info of $nick [$host]\n";
    print $remote "$nsnum O $$input[0] :Numeric        :$num\n";
    print $remote "$nsnum O $$input[0] :Server         :$server\n";
    if ($auth ne '0') {
	print $remote "$nsnum O $$input[0] :Identified as  :$auth\n"; 
	print $remote "$nsnum O $$input[0] :~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~\n";
	$sth=$dbh->prepare("SELECT email,showmail,lasthost,lastseen,cslvl FROM nicks WHERE rnick = '$auth';");
	$sth->execute;
	my @options = $sth->fetchrow_array;
	print $remote "$nsnum O $$input[0] :Email      :$options[0]\n";
	print $remote "$nsnum O $$input[0] :Show Email :$options[1]\n";
	print $remote "$nsnum O $$input[0] :Last Host  :$options[2]\n";
	$options[3] = localtime($options[3]);
	print $remote "$nsnum O $$input[0] :Last Seen  :$options[3]\n";
	print $remote "$nsnum O $$input[0] :CService   :$options[4] access\n" if $options[4] ne '0';
	undef @options;
    }
    else {
	print $remote "$nsnum O $$input[0] :Not Authenticated.\n";
    }
}

    1;
